﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;


namespace Final.App_Code
{
    public class subject_description
    {

        public List<Subject> List2()
        {
            List<Subject> result2 = new List<Subject>();
            SqlConnection conn = null;

            try
            {
                conn = new SqlConnection();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["SubjectManagementDBString"].ConnectionString;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection = conn;
                 
                comm.CommandText = "Select Subject_Name, Subject_Desc from Subj_Desc";
                SqlDataReader dr = comm.ExecuteReader();
                while (dr.Read())
                {
                    Subject sd = new Subject();
                    sd.Subjectname = (string)dr["Subject_Name"];
                   
                    sd.Subjectdesc = (string)dr["Subject_Desc"];
                    result2.Add(sd);
                }
                dr.Close();

            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return result2;
        }
    }
}